package com.mybatis.service.shop.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.mybatis.basic.entity.AjaxJson;
import com.mybatis.basic.entity.EasyuiList;
import com.mybatis.basic.service.impl.BasicServiceImpl;
import com.mybatis.dao.shop.GoodsPropertyDao;
import com.mybatis.dto.shop.Dto_GoodsType;
import com.mybatis.entity.shop.GoodsProperty;
import com.mybatis.service.shop.GoodsPropertyService;

@Service
public class GoodsPropertyServiceImpl extends BasicServiceImpl<GoodsProperty> implements GoodsPropertyService{

	private static final Logger Log = Logger.getLogger(GoodsPropertyServiceImpl.class);

	@Autowired
	private GoodsPropertyDao goodsPropertyDao;

	@Override
	public AjaxJson add(GoodsProperty goodsProperty) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			
			ajaxJson.setSuccess(true);
			ajaxJson.setMsg("添加成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false);
			ajaxJson.setMsg("程序出错，添加失败");
		}
		return ajaxJson;
	}

	@Override
	public AjaxJson queryOne(Integer id) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true);
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false);
			ajaxJson.setMsg("查询失败");
		}
		return ajaxJson;
	}

//	@Override
//	public AjaxJson queryListByPage(String typeName,String proName,Integer page,Integer rows) {
//		AjaxJson ajaxJson = new AjaxJson();
//		try {
//			PageHelper.startPage(page, rows);
//			List<Dto_GoodsType> list = goodsPropertyDao.queryListByPage(typeName, proName);
//			EasyuiList<Dto_GoodsType> result = new EasyuiList<>(list);
//			ajaxJson.setSuccess(true);
//			ajaxJson.setMsg("查询成功");
//			ajaxJson.setObj(result);
//		} catch (Exception e) {
//			e.printStackTrace();
//			ajaxJson.setSuccess(false);
//			ajaxJson.setMsg("程序出错，查询失败");
//		}
//		return ajaxJson;
//	}

	@Override
	public AjaxJson queryListByPage(GoodsProperty goodsProperty,Integer page,Integer rows) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			PageHelper.startPage(page, rows);
			List<GoodsProperty> list = goodsPropertyDao.queryListByPage(goodsProperty);
			EasyuiList<GoodsProperty> result = new EasyuiList<>(list);
			ajaxJson.setSuccess(true);
			ajaxJson.setMsg("查询成功");
			ajaxJson.setObj(result);
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false);
			ajaxJson.setMsg("程序出错，查询失败");
		}
		return ajaxJson;
	}

	@Override
	public AjaxJson del(Integer id) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false);
			ajaxJson.setMsg("程序错误，操作失败");
		}
		return ajaxJson;
	}

	@Override
	public AjaxJson mod(GoodsProperty goodsProperty) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false);
			ajaxJson.setMsg("程序错误，操作失败");
		}
		return ajaxJson;
	}
	
}
